<?php

namespace App\Models;

use Illuminate\Database\Eloquent\SoftDeletes;
use Watson\Validating\ValidatingTrait;
use Illuminate\Database\Eloquent\Model;

class AdminInfo extends Model
{
    use SoftDeletes;
    use ValidatingTrait;

    protected $table = 'admin_info';

    protected $fillable = ['name', 'mobile'];

    protected $rules = [
        'name'          => 'required',
        'mobile'        => ['required','regex:/^(([0-9]{5,25}))$/'],
    ];

    protected $validationMessages = [
        'name.required'          => '姓名必填',
        'mobile.required'        => '手机号码必填',
        'mobile.regex'           => '手机号格式有误',
    ];

    public static function getGgrZebianList()
    {
        $resultList = [];
        $zebianList = self::all();
        foreach ($zebianList as $zebian){
            $resultList[$zebian->id] = $zebian->name;
        }
        return $resultList;
    }
}
